﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace Problema2
{
    class MemoryDatabase : CustomDatabase
    {
        Hashtable tabel_comenzi;

        public MemoryDatabase()
        {
            tabel_comenzi = new Hashtable(1000);
        }
     
        public override void storeCustomer(Customer c)
        {
            Customer nou = c.Clone();                   // Prototype Pattern
            tabel_comenzi.Add(nou.Nume, nou.PC);
        }

        public override void afisare()
        {
            Console.WriteLine("Memory Database:");
            foreach(DictionaryEntry item in tabel_comenzi)
            {
                Console.Write(item.Key.ToString());
                Console.Write("\t");
                Console.Write(item.Value.ToString());
                Console.WriteLine();
            }
        }
        public override void sterge()
        {
            Console.WriteLine("Introduceti numele clientului pe care doriti sa-l stergeti:");
            string nume=Console.ReadLine();
            Hashtable tabel_nou;
            tabel_nou = new Hashtable(tabel_comenzi.Count);
            foreach (DictionaryEntry d in tabel_comenzi)
            {
                if (d.Key.ToString() != nume)
                    tabel_nou.Add(d.Key, d.Value);
            }
            tabel_comenzi = tabel_nou;
        }
    }
}
